/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package issr.boundary;

import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import issr.boundary.vaadin.MainApplication;
import issr.controller.ControlloreLogout;
import issr.entity.Utente;
import issr.misc.Labels;

/**
 *
 * @author Soulreaver
 */
public class PannelloLogout extends VerticalLayout implements Button.ClickListener {

    private ControlloreLogout controllore;
    private final Button logout;

    public PannelloLogout(Utente user) {
        controllore = new ControlloreLogout();
        setMargin(true);
        setWidth("200");
        setHeight("100");

        Label welcome = new Label("Benvenuto, " + user.getLogin());
        addComponent(welcome);

        logout = new Button(Labels.LOGOUT, this);
        addComponent(logout);
    }

    @Override
    public void buttonClick(ClickEvent e) {
        if (controllore.logout((Utente) MainApplication.getProject().getUser()) == true) {
            MainApplication.getProject().setUser(null);
        }
    }
}
